home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!nic.MR.NET!hal!ncoast!allbery
- From: bownesrm@beowulf.UUCP (Keptin Comrade Dr. Bob)
- Newsgroups: comp.sources.misc
- Subject: v05i087: Z80 Assembler/Disassembler part 2 of 3
- Message-ID: <1125@beowulf.UUCP>
- Date: 19 Dec 88 01:08:51 GMT
- Sender: allbery@ncoast.UUCP
- Reply-To: bownesrm@beowulf.UUCP (Keptin Comrade Dr. Bob)
- Organization: Reality Central
- Lines: 2439
- Approved: allbery@ncoast.UUCP
-
- Posting-number: Volume 5, Issue 87
- Submitted-by: "Keptin Comrade Dr. Bob" <bownesrm@beowulf.UUCP>
- Archive-name: z80ad/part02
-
- #!/bin/sh
- # this is part 2 of an archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file zmac/zdis.c continued
- #
- CurArch=2
- if test ! -r ._seq_
- then echo "Please unpack part 1 first!"
- exit 1; fi
- ( read Scheck
- if test "$Scheck" != $CurArch
- then echo "Please unpack part $Scheck next!"
- exit 1;
- else exit 0; fi
- ) < ._seq_ || exit 1
- sed 's/^X//' << 'SHAR_EOF' >> zmac/zdis.c
- X undefined, 0, /* ddf3 */
- X undefined, 0, /* ddf4 */
- X undefined, 0, /* ddf5 */
- X undefined, 0, /* ddf6 */
- X undefined, 0, /* ddf7 */
- X
- X undefined, 0, /* ddf8 */
- X "ld sp,ix", 0, /* ddf9 */
- X undefined, 0, /* ddfa */
- X undefined, 0, /* ddfb */
- X undefined, 0, /* ddfc */
- X undefined, 0, /* ddfd */
- X undefined, 0, /* ddfe */
- X undefined, 0, /* ddff */
- X /* ed */
- X undefined, 0, /* ed00 */
- X undefined, 0, /* ed01 */
- X undefined, 0, /* ed02 */
- X undefined, 0, /* ed03 */
- X undefined, 0, /* ed04 */
- X undefined, 0, /* ed05 */
- X undefined, 0, /* ed06 */
- X undefined, 0, /* ed07 */
- X
- X undefined, 0, /* ed08 */
- X undefined, 0, /* ed09 */
- X undefined, 0, /* ed0a */
- X undefined, 0, /* ed0b */
- X undefined, 0, /* ed0c */
- X undefined, 0, /* ed0d */
- X undefined, 0, /* ed0e */
- X undefined, 0, /* ed0f */
- X
- X undefined, 0, /* ed10 */
- X undefined, 0, /* ed11 */
- X undefined, 0, /* ed12 */
- X undefined, 0, /* ed13 */
- X undefined, 0, /* ed14 */
- X undefined, 0, /* ed15 */
- X undefined, 0, /* ed16 */
- X undefined, 0, /* ed17 */
- X
- X undefined, 0, /* ed18 */
- X undefined, 0, /* ed19 */
- X undefined, 0, /* ed1a */
- X undefined, 0, /* ed1b */
- X undefined, 0, /* ed1c */
- X undefined, 0, /* ed1d */
- X undefined, 0, /* ed1e */
- X undefined, 0, /* ed1f */
- X
- X undefined, 0, /* ed20 */
- X undefined, 0, /* ed21 */
- X undefined, 0, /* ed22 */
- X undefined, 0, /* ed23 */
- X undefined, 0, /* ed24 */
- X undefined, 0, /* ed25 */
- X undefined, 0, /* ed26 */
- X undefined, 0, /* ed27 */
- X
- X undefined, 0, /* ed28 */
- X undefined, 0, /* ed29 */
- X undefined, 0, /* ed2a */
- X undefined, 0, /* ed2b */
- X undefined, 0, /* ed2c */
- X undefined, 0, /* ed2d */
- X undefined, 0, /* ed2e */
- X undefined, 0, /* ed2f */
- X
- X undefined, 0, /* ed30 */
- X undefined, 0, /* ed31 */
- X undefined, 0, /* ed32 */
- X undefined, 0, /* ed33 */
- X undefined, 0, /* ed34 */
- X undefined, 0, /* ed35 */
- X undefined, 0, /* ed36 */
- X undefined, 0, /* ed37 */
- X
- X undefined, 0, /* ed38 */
- X undefined, 0, /* ed39 */
- X undefined, 0, /* ed3a */
- X undefined, 0, /* ed3b */
- X undefined, 0, /* ed3c */
- X undefined, 0, /* ed3d */
- X undefined, 0, /* ed3e */
- X undefined, 0, /* ed3f */
- X
- X "in b,(c)", 0, /* ed40 */
- X "out (c),b", 0, /* ed41 */
- X "sbc hl,bc", 0, /* ed42 */
- X "ld (%02x%02xh),bc",2, /* ed43 */
- X "neg", 0, /* ed44 */
- X "retn", 0, /* ed45 */
- X "im 0", 0, /* ed46 */
- X "ld i,a", 0, /* ed47 */
- X
- X "in c,(c)", 0, /* ed48 */
- X "out (c),c", 0, /* ed49 */
- X "adc hl,bc", 0, /* ed4a */
- X "ld bc,(%02x%02xh)",2, /* ed4b */
- X undefined, 0, /* ed4c */
- X "reti", 0, /* ed4d */
- X undefined, 0, /* ed4e */
- X undefined, 0, /* ed4f */
- X
- X "in d,(c)", 0, /* ed50 */
- X "out (c),d", 0, /* ed51 */
- X "sbc hl,de", 0, /* ed52 */
- X "ld (%02x%02xh),de",2, /* ed53 */
- X undefined, 0, /* ed54 */
- X undefined, 0, /* ed55 */
- X "im 1", 0, /* ed56 */
- X "ld a,i", 0, /* ed57 */
- X
- X "in e,(c)", 0, /* ed58 */
- X "out (c),e", 0, /* ed59 */
- X "adc hl,de", 0, /* ed5a */
- X "ld de,(%02x%02xh)",2, /* ed5b */
- X undefined, 0, /* ed5c */
- X undefined, 0, /* ed5d */
- X "im 2", 0, /* ed5e */
- X undefined, 0, /* ed5f */
- X
- X "in h,(c)", 0, /* ed60 */
- X "out (c),h", 0, /* ed61 */
- X "sbc hl,hl", 0, /* ed62 */
- X undefined, 0, /* ed63 */
- X undefined, 0, /* ed64 */
- X undefined, 0, /* ed65 */
- X undefined, 0, /* ed66 */
- X "rrd", 0, /* ed67 */
- X
- X "in l,(c)", 0, /* ed68 */
- X "out (c),l", 0, /* ed69 */
- X "adc hl,hl", 0, /* ed6a */
- X undefined, 0, /* ed6b */
- X undefined, 0, /* ed6c */
- X undefined, 0, /* ed6d */
- X undefined, 0, /* ed6e */
- X "rld", 0, /* ed6f */
- X
- X undefined, 0, /* ed70 */
- X undefined, 0, /* ed71 */
- X "sbc hl,sp", 0, /* ed72 */
- X "ld (%02x%02xh),sp",2, /* ed73 */
- X undefined, 0, /* ed74 */
- X undefined, 0, /* ed75 */
- X undefined, 0, /* ed76 */
- X undefined, 0, /* ed77 */
- X
- X "in a,(c)", 0, /* ed78 */
- X "out (c),a", 0, /* ed79 */
- X "adc hl,sp", 0, /* ed7a */
- X "ld sp,(%02x%02xh)",2, /* ed7b */
- X undefined, 0, /* ed7c */
- X undefined, 0, /* ed7d */
- X undefined, 0, /* ed7e */
- X undefined, 0, /* ed7f */
- X
- X undefined, 0, /* ed80 */
- X undefined, 0, /* ed81 */
- X undefined, 0, /* ed82 */
- X undefined, 0, /* ed83 */
- X undefined, 0, /* ed84 */
- X undefined, 0, /* ed85 */
- X undefined, 0, /* ed86 */
- X undefined, 0, /* ed87 */
- X
- X undefined, 0, /* ed88 */
- X undefined, 0, /* ed89 */
- X undefined, 0, /* ed8a */
- X undefined, 0, /* ed8b */
- X undefined, 0, /* ed8c */
- X undefined, 0, /* ed8d */
- X undefined, 0, /* ed8e */
- X undefined, 0, /* ed8f */
- X
- X undefined, 0, /* ed90 */
- X undefined, 0, /* ed91 */
- X undefined, 0, /* ed92 */
- X undefined, 0, /* ed93 */
- X undefined, 0, /* ed94 */
- X undefined, 0, /* ed95 */
- X undefined, 0, /* ed96 */
- X undefined, 0, /* ed97 */
- X
- X undefined, 0, /* ed98 */
- X undefined, 0, /* ed99 */
- X undefined, 0, /* ed9a */
- X undefined, 0, /* ed9b */
- X undefined, 0, /* ed9c */
- X undefined, 0, /* ed9d */
- X undefined, 0, /* ed9e */
- X undefined, 0, /* ed9f */
- X
- X "ldi", 0, /* eda0 */
- X "cpi", 0, /* eda1 */
- X "ini", 0, /* eda2 */
- X "outi", 0, /* eda3 */
- X undefined, 0, /* eda4 */
- X undefined, 0, /* eda5 */
- X undefined, 0, /* eda6 */
- X undefined, 0, /* eda7 */
- X
- X "ldd", 0, /* eda8 */
- X "cpd", 0, /* eda9 */
- X "ind", 0, /* edaa */
- X "outd", 0, /* edab */
- X undefined, 0, /* edac */
- X undefined, 0, /* edad */
- X undefined, 0, /* edae */
- X undefined, 0, /* edaf */
- X
- X "ldir", 0, /* edb0 */
- X "cpir", 0, /* edb1 */
- X "inir", 0, /* edb2 */
- X "otir", 0, /* edb3 */
- X undefined, 0, /* edb4 */
- X undefined, 0, /* edb5 */
- X undefined, 0, /* edb6 */
- X undefined, 0, /* edb7 */
- X
- X "lddr", 0, /* edb8 */
- X "cpdr", 0, /* edb9 */
- X "indr", 0, /* edba */
- X "otdr", 0, /* edbb */
- X undefined, 0, /* edbc */
- X undefined, 0, /* edbd */
- X undefined, 0, /* edbe */
- X undefined, 0, /* edbf */
- X
- X undefined, 0, /* edc0 */
- X undefined, 0, /* edc1 */
- X undefined, 0, /* edc2 */
- X undefined, 0, /* edc3 */
- X undefined, 0, /* edc4 */
- X undefined, 0, /* edc5 */
- X undefined, 0, /* edc6 */
- X undefined, 0, /* edc7 */
- X
- X undefined, 0, /* edc8 */
- X undefined, 0, /* edc9 */
- X undefined, 0, /* edca */
- X undefined, 0, /* edcb */
- X undefined, 0, /* edcc */
- X undefined, 0, /* edcd */
- X undefined, 0, /* edce */
- X undefined, 0, /* edcf */
- X
- X undefined, 0, /* edd0 */
- X undefined, 0, /* edd1 */
- X undefined, 0, /* edd2 */
- X undefined, 0, /* edd3 */
- X undefined, 0, /* edd4 */
- X undefined, 0, /* edd5 */
- X undefined, 0, /* edd6 */
- X undefined, 0, /* edd7 */
- X
- X undefined, 0, /* edd8 */
- X undefined, 0, /* edd9 */
- X undefined, 0, /* edda */
- X undefined, 0, /* eddb */
- X undefined, 0, /* eddc */
- X undefined, 0, /* eddd */
- X undefined, 0, /* edde */
- X undefined, 0, /* eddf */
- X
- X undefined, 0, /* ede0 */
- X undefined, 0, /* ede1 */
- X undefined, 0, /* ede2 */
- X undefined, 0, /* ede3 */
- X undefined, 0, /* ede4 */
- X undefined, 0, /* ede5 */
- X undefined, 0, /* ede6 */
- X undefined, 0, /* ede7 */
- X
- X undefined, 0, /* ede8 */
- X undefined, 0, /* ede9 */
- X undefined, 0, /* edea */
- X undefined, 0, /* edeb */
- X undefined, 0, /* edec */
- X undefined, 0, /* eded */
- X undefined, 0, /* edee */
- X undefined, 0, /* edef */
- X
- X undefined, 0, /* edf0 */
- X undefined, 0, /* edf1 */
- X undefined, 0, /* edf2 */
- X undefined, 0, /* edf3 */
- X undefined, 0, /* edf4 */
- X undefined, 0, /* edf5 */
- X undefined, 0, /* edf6 */
- X undefined, 0, /* edf7 */
- X
- X undefined, 0, /* edf8 */
- X undefined, 0, /* edf9 */
- X undefined, 0, /* edfa */
- X undefined, 0, /* edfb */
- X undefined, 0, /* edfc */
- X undefined, 0, /* edfd */
- X undefined, 0, /* edfe */
- X undefined, 0, /* edff */
- X /* fd */
- X undefined, 0, /* fd00 */
- X undefined, 0, /* fd01 */
- X undefined, 0, /* fd02 */
- X undefined, 0, /* fd03 */
- X undefined, 0, /* fd04 */
- X undefined, 0, /* fd05 */
- X undefined, 0, /* fd06 */
- X undefined, 0, /* fd07 */
- X
- X undefined, 0, /* fd08 */
- X "add iy,bc", 0, /* fd09 */
- X undefined, 0, /* fd0a */
- X undefined, 0, /* fd0b */
- X undefined, 0, /* fd0c */
- X undefined, 0, /* fd0d */
- X undefined, 0, /* fd0e */
- X undefined, 0, /* fd0f */
- X
- X undefined, 0, /* fd10 */
- X undefined, 0, /* fd11 */
- X undefined, 0, /* fd12 */
- X undefined, 0, /* fd13 */
- X undefined, 0, /* fd14 */
- X undefined, 0, /* fd15 */
- X undefined, 0, /* fd16 */
- X undefined, 0, /* fd17 */
- X
- X undefined, 0, /* fd18 */
- X "add iy,de", 0, /* fd19 */
- X undefined, 0, /* fd1a */
- X undefined, 0, /* fd1b */
- X undefined, 0, /* fd1c */
- X undefined, 0, /* fd1d */
- X undefined, 0, /* fd1e */
- X undefined, 0, /* fd1f */
- X
- X undefined, 0, /* fd20 */
- X "ld iy,%02x%02xh", 2, /* fd21 */
- X "ld (%02x%02xh),iy",2, /* fd22 */
- X "inc iy", 0, /* fd23 */
- X undefined, 0, /* fd24 */
- X undefined, 0, /* fd25 */
- X undefined, 0, /* fd26 */
- X undefined, 0, /* fd27 */
- X
- X undefined, 0, /* fd28 */
- X "add iy,iy", 0, /* fd29 */
- X "ld iy,(%02x%02xh)",2, /* fd2a */
- X "dec iy", 0, /* fd2b */
- X undefined, 0, /* fd2c */
- X undefined, 0, /* fd2d */
- X undefined, 0, /* fd2e */
- X undefined, 0, /* fd2f */
- X
- X undefined, 0, /* fd30 */
- X undefined, 0, /* fd31 */
- X undefined, 0, /* fd32 */
- X undefined, 0, /* fd33 */
- X "inc (iy+%02xh)", 1, /* fd34 */
- X "dec (iy+%02xh)", 1, /* fd35 */
- X "ld (iy+%02xh),%02xh",2, /* fd36 */
- X undefined, 0, /* fd37 */
- X
- X undefined, 0, /* fd38 */
- X "add iy,sp", 0, /* fd39 */
- X undefined, 0, /* fd3a */
- X undefined, 0, /* fd3b */
- X undefined, 0, /* fd3c */
- X undefined, 0, /* fd3d */
- X undefined, 0, /* fd3e */
- X undefined, 0, /* fd3f */
- X
- X undefined, 0, /* fd40 */
- X undefined, 0, /* fd41 */
- X undefined, 0, /* fd42 */
- X undefined, 0, /* fd43 */
- X undefined, 0, /* fd44 */
- X undefined, 0, /* fd45 */
- X "ld b,(iy+%02xh)", 1, /* fd46 */
- X undefined, 0, /* fd47 */
- X
- X undefined, 0, /* fd48 */
- X undefined, 0, /* fd49 */
- X undefined, 0, /* fd4a */
- X undefined, 0, /* fd4b */
- X undefined, 0, /* fd4c */
- X undefined, 0, /* fd4d */
- X "ld c,(iy+%02xh)", 1, /* fd4e */
- X undefined, 0, /* fd4f */
- X
- X undefined, 0, /* fd50 */
- X undefined, 0, /* fd51 */
- X undefined, 0, /* fd52 */
- X undefined, 0, /* fd53 */
- X undefined, 0, /* fd54 */
- X undefined, 0, /* fd55 */
- X "ld d,(iy+%02xh)", 1, /* fd56 */
- X undefined, 0, /* fd57 */
- X
- X undefined, 0, /* fd58 */
- X undefined, 0, /* fd59 */
- X undefined, 0, /* fd5a */
- X undefined, 0, /* fd5b */
- X undefined, 0, /* fd5c */
- X undefined, 0, /* fd5d */
- X "ld e,(iy+%02xh)", 1, /* fd5e */
- X undefined, 0, /* fd5f */
- X
- X undefined, 0, /* fd60 */
- X undefined, 0, /* fd61 */
- X undefined, 0, /* fd62 */
- X undefined, 0, /* fd63 */
- X undefined, 0, /* fd64 */
- X undefined, 0, /* fd65 */
- X "ld h,(iy+%02xh)", 1, /* fd66 */
- X undefined, 0, /* fd67 */
- X
- X undefined, 0, /* fd68 */
- X undefined, 0, /* fd69 */
- X undefined, 0, /* fd6a */
- X undefined, 0, /* fd6b */
- X undefined, 0, /* fd6c */
- X undefined, 0, /* fd6d */
- X "ld l,(iy+%02xh)", 1, /* fd6e */
- X undefined, 0, /* fd6f */
- X
- X "ld (iy+%02xh),b", 1, /* fd70 */
- X "ld (iy+%02xh),c", 1, /* fd71 */
- X "ld (iy+%02xh),d", 1, /* fd72 */
- X "ld (iy+%02xh),e", 1, /* fd73 */
- X "ld (iy+%02xh),h", 1, /* fd74 */
- X "ld (iy+%02xh),l", 1, /* fd75 */
- X undefined, 0, /* fd76 */
- X "ld (iy+%02xh),a", 1, /* fd77 */
- X
- X undefined, 0, /* fd78 */
- X undefined, 0, /* fd79 */
- X undefined, 0, /* fd7a */
- X undefined, 0, /* fd7b */
- X undefined, 0, /* fd7c */
- X undefined, 0, /* fd7d */
- X "ld a,(iy+%02xh)", 1, /* fd7e */
- X undefined, 0, /* fd7f */
- X
- X undefined, 0, /* fd80 */
- X undefined, 0, /* fd81 */
- X undefined, 0, /* fd82 */
- X undefined, 0, /* fd83 */
- X undefined, 0, /* fd84 */
- X undefined, 0, /* fd85 */
- X "add a,(iy+%02xh)", 1, /* fd86 */
- X undefined, 0, /* fd87 */
- X
- X undefined, 0, /* fd88 */
- X undefined, 0, /* fd89 */
- X undefined, 0, /* fd8a */
- X undefined, 0, /* fd8b */
- X undefined, 0, /* fd8c */
- X undefined, 0, /* fd8d */
- X "adc a,(iy+%02xh)", 1, /* fd8e */
- X undefined, 0, /* fd8f */
- X
- X undefined, 0, /* fd90 */
- X undefined, 0, /* fd91 */
- X undefined, 0, /* fd92 */
- X undefined, 0, /* fd93 */
- X undefined, 0, /* fd94 */
- X undefined, 0, /* fd95 */
- X "sub (iy+%02xh)", 1, /* fd96 */
- X undefined, 0, /* fd97 */
- X
- X undefined, 0, /* fd98 */
- X undefined, 0, /* fd99 */
- X undefined, 0, /* fd9a */
- X undefined, 0, /* fd9b */
- X undefined, 0, /* fd9c */
- X undefined, 0, /* fd9d */
- X "sbc a,(iy+%02xh)", 1, /* fd9e */
- X undefined, 0, /* fd9f */
- X
- X undefined, 0, /* fda0 */
- X undefined, 0, /* fda1 */
- X undefined, 0, /* fda2 */
- X undefined, 0, /* fda3 */
- X undefined, 0, /* fda4 */
- X undefined, 0, /* fda5 */
- X "and (iy+%02xh)", 1, /* fda6 */
- X undefined, 0, /* fda7 */
- X
- X undefined, 0, /* fda8 */
- X undefined, 0, /* fda9 */
- X undefined, 0, /* fdaa */
- X undefined, 0, /* fdab */
- X undefined, 0, /* fdac */
- X undefined, 0, /* fdad */
- X "xor (iy+%02xh)", 1, /* fdae */
- X undefined, 0, /* fdaf */
- X
- X undefined, 0, /* fdb0 */
- X undefined, 0, /* fdb1 */
- X undefined, 0, /* fdb2 */
- X undefined, 0, /* fdb3 */
- X undefined, 0, /* fdb4 */
- X undefined, 0, /* fdb5 */
- X "or (iy+%02xh)", 1, /* fdb6 */
- X undefined, 0, /* fdb7 */
- X
- X undefined, 0, /* fdb8 */
- X undefined, 0, /* fdb9 */
- X undefined, 0, /* fdba */
- X undefined, 0, /* fdbb */
- X undefined, 0, /* fdbc */
- X undefined, 0, /* fdbd */
- X "cp (iy+%02xh)", 1, /* fdbe */
- X undefined, 0, /* fdbf */
- X
- X undefined, 0, /* fdc0 */
- X undefined, 0, /* fdc1 */
- X undefined, 0, /* fdc2 */
- X undefined, 0, /* fdc3 */
- X undefined, 0, /* fdc4 */
- X undefined, 0, /* fdc5 */
- X undefined, 0, /* fdc6 */
- X undefined, 0, /* fdc7 */
- X
- X undefined, 0, /* fdc8 */
- X undefined, 0, /* fdc9 */
- X undefined, 0, /* fdca */
- X "fd cb %02x,%02x", 2, /* fdcb */
- X undefined, 0, /* fdcc */
- X undefined, 0, /* fdcd */
- X undefined, 0, /* fdce */
- X undefined, 0, /* fdcf */
- X
- X undefined, 0, /* fdd0 */
- X undefined, 0, /* fdd1 */
- X undefined, 0, /* fdd2 */
- X undefined, 0, /* fdd3 */
- X undefined, 0, /* fdd4 */
- X undefined, 0, /* fdd5 */
- X undefined, 0, /* fdd6 */
- X undefined, 0, /* fdd7 */
- X
- X undefined, 0, /* fdd8 */
- X undefined, 0, /* fdd9 */
- X undefined, 0, /* fdda */
- X undefined, 0, /* fddb */
- X undefined, 0, /* fddc */
- X undefined, 0, /* fddd */
- X undefined, 0, /* fdde */
- X undefined, 0, /* fddf */
- X
- X undefined, 0, /* fde0 */
- X "pop iy", 0, /* fde1 */
- X undefined, 0, /* fde2 */
- X "ex (sp),iy", 0, /* fde3 */
- X undefined, 0, /* fde4 */
- X "push iy", 0, /* fde5 */
- X undefined, 0, /* fde6 */
- X undefined, 0, /* fde7 */
- X
- X undefined, 0, /* fde8 */
- X "jp (iy)", 0, /* fde9 */
- X undefined, 0, /* fdea */
- X undefined, 0, /* fdeb */
- X undefined, 0, /* fdec */
- X undefined, 0, /* fded */
- X undefined, 0, /* fdee */
- X undefined, 0, /* fdef */
- X
- X undefined, 0, /* fdf0 */
- X undefined, 0, /* fdf1 */
- X undefined, 0, /* fdf2 */
- X undefined, 0, /* fdf3 */
- X undefined, 0, /* fdf4 */
- X undefined, 0, /* fdf5 */
- X undefined, 0, /* fdf6 */
- X undefined, 0, /* fdf7 */
- X
- X undefined, 0, /* fdf8 */
- X "ld sp,iy", 0, /* fdf9 */
- X undefined, 0, /* fdfa */
- X undefined, 0, /* fdfb */
- X undefined, 0, /* fdfc */
- X undefined, 0, /* fdfd */
- X undefined, 0, /* fdfe */
- X undefined, 0, /* fdff */
- X};
- X
- Xint curaddr = 0;
- X
- Xmain ()
- X{
- X int i, j, arg1, arg2;
- X struct opcode *code;
- X int addr;
- X
- X for (;;) {
- X addr = curaddr;
- X i = gethex();
- X if (!major[i].name) {
- X j = major[i].args;
- X i = gethex();
- X while (!minor[j][i].name) {
- X j = minor[j][i].args;
- X i = gethex ();
- X }
- X code = &minor[j][i];
- X } else
- X code = &major[i];
- X printf ("%04x\t", addr);
- X switch (code->args) {
- X case 2:
- X printf (code->name, gethex(), gethex());
- X break;
- X case 1:
- X printf (code->name, gethex());
- X break;
- X case 0:
- X printf (code->name);
- X break;
- X }
- X putchar ('\n');
- X }
- X}
- X
- Xint inline;
- Xint index;
- X
- Xchar linebuf[1024];
- X
- Xint hexbuf[1024];
- X
- Xgethex ()
- X{
- X if (index == inline) {
- X again: ;
- X if (gets (linebuf) == 0)
- X exit (0);
- X if (strlen (linebuf) < 9)
- X goto again;
- X inline = fromhex (linebuf+1);
- X for (index = 0; index < inline; index++)
- X hexbuf[index] = fromhex (linebuf+9 + 2 * index);
- X index = 0;
- X }
- X ++curaddr;
- X return hexbuf[index++];
- X}
- X
- X#define hexval(c) (('0' <= (c) && (c) <= '9') ? (c) - '0' :\
- X (('a' <= (c) && (c) <= 'f') ? (c) - 'a' + 10 :\
- X (('A' <= (c) && (c) <= 'F') ? (c) - 'A' + 10 :\
- X -1 )))
- X
- Xfromhex (c)
- Xchar *c;
- X{
- X return hexval(c[0]) * 16 + hexval(c[1]);
- X}
- SHAR_EOF
- chmod 0755 zmac/zdis.c
- sed 's/^X//' << 'SHAR_EOF' > zmac/zmac.1
- X.TH ZMAC l
- X.SH NAME
- Xzmac \- macro cross-assembler for the Zilog Z80 microprocessor
- X.SH SYNOPSIS
- Xzmac [-bdefgilLmnopst] infile
- X.SH DESCRIPTION
- XThe
- X.I Zmac
- Xassembler is modeled after the Intel 8080 macro cross-assembler
- Xfor the Intel 8080 by Ken Borgendale. The major features are: Full
- Xmacro capabilities, Conditional assembly, A very flexible set of
- Xlisting options and pseudo-ops, Symbol table output, Error report,
- XElimination of sequential searching, Commenting of source, Facilities
- Xfor system definiton files.
- X.PP
- X.I Zmac
- Xassembles the specified input file (default extension .z) and
- Xproduces a .hex output file. The options are:
- X.TP 8
- X.B b
- Xno binary
- X.TP 8
- X.B d
- Xdebug
- X.TP 8
- X.B e
- Xerror list only
- X.TP 8
- X.B f
- Xprint if skipped lines
- X.TP 8
- X.B g
- Xdo not list extra code
- X.TP 8
- X.B i
- Xdo not list include files
- X.TP 8
- X.B l
- Xno list
- X.TP 8
- X.B L
- Xforce listing of everything
- X.TP 8
- X.B m
- Xprint macro expansions
- X.TP 8
- X.B n
- Xput line numbers off
- X.TP 8
- X.B o
- Xlist to standard output
- X.TP 8
- X.B p
- Xput out four \\n's for eject
- X.TP 8
- X.B s
- Xdon't produce a symbol list
- X.TP 8
- X.B t
- Xdon't know what this option does
- X.SH SEE ALSO
- Xzdis(l)
- X.SH FILES
- XSource is in /usr/local/src/zmac directory.
- X.SH BUGS
- XThe man page is incomplete. If anyone discovers more information about
- Xusing zmac, please consider helping to update the man page.
- SHAR_EOF
- chmod 0755 zmac/zmac.1
- sed 's/^X//' << 'SHAR_EOF' > zmac/zmac.y
- X%{
- X/*
- X * zmac -- macro cross-assembler for the Zilog Z80 microprocessor
- X *
- X * Bruce Norskog 4/78
- X *
- X * Last modification 1-18-87 by cdk
- X * This assembler is modeled after the Intel 8080 macro cross-assembler
- X * for the Intel 8080 by Ken Borgendale. The major features are:
- X * 1. Full macro capabilities
- X * 2. Conditional assembly
- X * 3. A very flexible set of listing options and pseudo-ops
- X * 4. Symbol table output
- X * 5. Error report
- X * 6. Elimination of sequential searching
- X * 7. Commenting of source
- X * 8. Facilities for system definiton files
- X *
- X * Revision History:
- X *
- X * jrp 3-8-82 Converted to run on Vax, updated syntax to conform better
- X * to the Zilog standard.
- X *
- X * jrp 3-15-82 Added underscore as a character type in the lex table
- X * 'numpart' (0x5F).
- X *
- X * Changed maximum number of characters in a label to 15
- X * from 7. Note that 'putsymtab' uses this value inside
- X * of a quoted string, so we use 15.
- X *
- X * jrp 2-15-83 Fixed 'getlocal' to return better local labels. It used
- X * to crash after 6 invocations.
- X *
- X * jrp 6-7-83 Fixed bug in the ADD IX,... instruction.
- X *
- X * jrp 5-11-84 Added code to print unused labels out with the symbol table
- X * Also sped up the macro processor by using stdio.
- X *
- X * jrp 5-22-84 Added include files ala ormac
- X *
- X * jrp 8-27-84 Added PHASE/DEPHASE commands
- X *
- X * cdk 9-20-86 Converted to run on a Pyramid. This meant changing yylval
- X * to be a %union, and then putting in the appropriate
- X * typecasts where ints are pointers are used interchangeably.
- X * The current version still probably won't run on machines where
- X * sizeof(int) != sizeof(char *).
- X * Also changed emit() to use varargs, and got rid of the
- X * old style = in front of yacc action code.
- X * -Colin Kelley vu-vlsi!colin
- X *
- X * cdk 10-2-86 Added some more typecasts to keep lint a little happier.
- X * Removed several unused variables. Changed most vars
- X * declared as char to int, since many of them were being
- X * compared with -1! I still don't know what's going on with
- X * est[][] being malloc'd and free'd everywhere...it looks pretty
- X * fishy...
- X *
- X * cdk 1-18-87 Added MIO code to emulate 'mfile' using malloc()'d memory.
- X * This was needed to get the code to work when compiled under
- X * MSC 4.0 on a PC, and it's probably faster anyway.
- X *
- X * cdk 2-5-87 Added 'cmp' as a synonym for 'cp', 'jmp' as a synonym for
- X * 'jp', and added tolerance of accumulator specification for arithmetic
- X * and logical instructions. (For example, 'or a,12' is now accepted,
- X * same as 'or 12'.)
- X */
- X
- X
- X#define MIO /* use emulation routines from mio.c */
- X
- X#include <stdio.h>
- X#ifdef MSDOS
- X#include <fcntl.h>
- X#else
- X#include <sys/file.h> /* for open() calls */
- X#endif
- X
- X#ifdef vax11c
- X#define unlink(filename) delete(filename)
- X#endif
- X
- X#ifdef MIO
- XFILE *mfopen();
- X#else
- X#define mfopen(filename,mode) fopen(filename,mode)
- X#define mfclose(filename,mode) fclose(filename,mode)
- X#define mfputc(c,f) putc(c,f)
- X#define mfgetc(f) getc(f)
- X#define mfseek(f,loc,origin) fseek(f,loc,origin)
- X#define mfread(ptr,size,nitems,f) fread(ptr,size,nitems,f)
- X#define mfwrite(ptr,size,nitems,f) fread(ptr,size,nitems,f)
- X#endif /* MIO */
- X
- X/*
- X * DEBUG turns on pass reporting.
- X * Macro debug and Token debug enables.
- X#define DEBUG
- X#define M_DEBUG
- X#define T_DEBUG
- X */
- X
- X#define ITEMTABLESIZE 2000
- X#define TEMPBUFSIZE 200
- X#define LINEBUFFERSIZE 200
- X#define EMITBUFFERSIZE 200
- X#define MAXSYMBOLSIZE 15
- X#define IFSTACKSIZE 20
- X#define MAXIFS 150
- X#define TITLELEN 50
- X#define BINPERLINE 16
- X#define PARMMAX 25
- X#define MAXEXP 25
- X#define SYMMAJIC 07203
- X#define NEST_IN 8
- X
- X
- X#define loop for(;;)
- X
- Xyyerror(err)
- Xchar *err;
- X{} /* we will do our own error printing */
- X
- Xstruct item {
- X char *i_string;
- X int i_value;
- X int i_token;
- X int i_uses;
- X};
- X
- XFILE *fout,
- X *fbuf,
- X *fin[NEST_IN],
- X *now_file ;
- X
- Xchar *malloc() ;
- X
- Xint pass2; /*set when pass one completed*/
- Xint dollarsign ; /* location counter */
- Xint olddollar ; /* kept to put out binary */
- X
- X/* program counter save for PHASE/DEPHASE */
- Xint phdollar, phbegin, phaseflag ;
- X
- Xchar *src_name[NEST_IN] ;
- Xint linein[NEST_IN] ;
- Xint now_in ;
- X
- X
- X
- X#define bflag 0 /* balance error */
- X#define eflag 1 /* expression error */
- X#define fflag 2 /* format error */
- X#define iflag 3 /* bad digits */
- X#define mflag 4 /* multiply defined */
- X#define pflag 5 /* phase error */
- X#define uflag 6 /* undeclared used */
- X#define vflag 7 /* value out of range */
- X#define oflag 8 /* phase/dephase error */
- X
- X#define FLAGS 9 /* number of flags */
- X
- Xchar err[FLAGS];
- Xint keeperr[FLAGS];
- Xchar errlet[]="BEFIMPUVO";
- Xchar *errname[]={
- X "Balance",
- X "Expression",
- X "Format",
- X "Digit",
- X "Mult. def.",
- X "Phase",
- X "Undeclared",
- X "Value",
- X "Phase/Dephase",
- X};
- X
- X
- Xchar linebuf[LINEBUFFERSIZE];
- Xchar *lineptr;
- Xchar *linemax = &linebuf[LINEBUFFERSIZE];
- X
- Xchar outbin[BINPERLINE];
- Xchar *outbinp = outbin;
- Xchar *outbinm = &outbin[BINPERLINE];
- X
- Xchar emitbuf[EMITBUFFERSIZE];
- Xchar *emitptr;
- X
- Xchar ifstack[IFSTACKSIZE];
- Xchar *ifptr;
- Xchar *ifstmax = &ifstack[IFSTACKSIZE-1];
- X
- X
- Xchar expif[MAXIFS];
- Xchar *expifp;
- Xchar *expifmax = &expif[MAXIFS];
- X
- Xchar hexadec[] = "0123456789ABCDEF" ;
- Xchar *expstack[MAXEXP];
- Xint expptr;
- X
- X
- Xint nitems;
- Xint linecnt;
- Xint nbytes;
- Xint invented;
- X
- X
- Xchar tempbuf[TEMPBUFSIZE];
- Xchar *tempmax = &tempbuf[TEMPBUFSIZE-1];
- X
- Xchar inmlex;
- Xchar arg_flag;
- Xchar quoteflag;
- Xint parm_number;
- Xint exp_number;
- Xchar symlong[] = "Symbol too long";
- X
- Xint disp;
- X#define FLOC PARMMAX
- X#define TEMPNUM PARMMAX+1
- Xchar **est;
- Xchar **est2;
- X
- Xchar *floc;
- Xint mfptr;
- XFILE *mfile;
- X
- Xchar *writesyms;
- X
- X
- Xchar *title;
- Xchar titlespace[TITLELEN];
- Xchar *timp,*ctime();
- Xchar *sourcef;
- Xchar src[15];
- Xchar bin[15];
- Xchar mtmp[15];
- Xchar listf[15];
- X
- Xchar bopt = 1,
- X edef = 1,
- X eopt = 1,
- X fdef = 0,
- X fopt = 0,
- X gdef = 1,
- X gopt = 1,
- X iopt = 0 , /* list include files */
- X lstoff = 0,
- X lston = 0, /* flag to force listing on */
- X lopt = 0,
- X mdef = 0,
- X mopt = 0,
- X nopt = 1 , /* line numbers on as default */
- X oopt = 0,
- X popt = 1, /* form feed as default page eject */
- X sopt = 0, /* turn on symbol table listing */
- X topt = 1;
- X saveopt;
- X
- Xchar xeq_flag = 0;
- Xint xeq;
- X
- Xlong now;
- Xint line;
- Xint page = 1;
- X
- Xstruct stab {
- X char t_name[MAXSYMBOLSIZE+1];
- X int t_value;
- X int t_token;
- X};
- X
- X/*
- X * push back character
- X */
- Xint peekc;
- X
- X
- X/*
- X * add a character to the output line buffer
- X */
- Xaddtoline(ac)
- Xint ac;
- X{
- X /* check for EOF from stdio */
- X if (ac == -1)
- X ac = 0 ;
- X if (inmlex)
- X return(ac);
- X if (lineptr >= linemax)
- X error("line buffer overflow");
- X *lineptr++ = ac;
- X return(ac);
- X}
- X
- X#include <varargs.h>
- X
- X/*
- X * put values in buffer for outputing
- X */
- X
- X/*VARARGS*/
- X/*ARGSUSED*/
- Xemit(va_alist)
- Xva_dcl
- X{
- X register int bytes;
- X va_list ap;
- X va_start(ap);
- X
- X bytes = va_arg(ap,int);
- X
- X while (--bytes >= 0)
- X if (emitptr >= &emitbuf[EMITBUFFERSIZE])
- X error("emit buffer overflow");
- X else {
- X *emitptr++ = va_arg(ap,int);
- X }
- X va_end(ap);
- X}
- X
- X
- Xemit1(opcode,regvalh,data16,type)
- Xint opcode,regvalh,data16,type;
- X{
- X if (regvalh & 0x8000) {
- X if (type & 1 == 0 && (disp > 127 || disp < -128))
- X err[vflag]++;
- X switch(type) {
- X case 0:
- X if (opcode & 0x8000)
- X emit(4, regvalh >> 8, opcode >> 8, disp, opcode);
- X else
- X emit(3, regvalh >> 8, opcode, disp);
- X break;
- X case 1:
- X emit(2, regvalh >> 8, opcode);
- X break;
- X case 2:
- X if (data16 > 255 || data16 < -128)
- X err[vflag]++;
- X emit(4, regvalh >> 8, opcode, disp, data16);
- X break;
- X case 5:
- X emit(4, regvalh >> 8, opcode, data16, data16 >> 8);
- X }
- X } else
- X switch(type) {
- X case 0:
- X if (opcode & 0100000)
- X emit(2, opcode >> 8, opcode);
- X else
- X emit(1, opcode);
- X break;
- X case 1:
- X if (opcode & 0100000)
- X emit(2, opcode >> 8, opcode);
- X else
- X emit(1, opcode);
- X break;
- X case 2:
- X if (data16 > 255 || data16 < -128)
- X err[vflag]++;
- X emit(2, opcode, data16);
- X break;
- X case 3:
- X if (data16 >255 || data16 < -128)
- X err[vflag]++;
- X emit(2, opcode, data16);
- X break;
- X case 5:
- X if (opcode & 0100000)
- X emit(4, opcode >> 8, opcode, data16, data16 >> 8);
- X else
- X emit(3, opcode, data16, data16 >> 8);
- X }
- X}
- X
- X
- X
- X
- Xemitdad(rp1,rp2)
- Xint rp1,rp2;
- X{
- X if (rp1 & 0x8000)
- X emit(2,rp1 >> 8, rp2 + 9);
- X else
- X emit(1,rp2 + 9);
- X}
- X
- X
- Xemitjr(opcode,expr)
- Xint opcode,expr;
- X{
- X disp = expr - dollarsign - 2;
- X if (disp > 127 || disp < -128)
- X err[vflag]++;
- X emit(2, opcode, disp);
- X}
- X
- X
- X
- X
- X/*
- X * put out a byte of binary
- X */
- Xputbin(v)
- X{
- X if(!pass2 || !bopt) return;
- X *outbinp++ = v;
- X if (outbinp >= outbinm) flushbin();
- X}
- X
- X
- X
- X/*
- X * output one line of binary in INTEL standard form
- X */
- Xflushbin()
- X{
- X register char *p;
- X register check;
- X
- X if (!pass2 || !bopt)
- X return;
- X nbytes += outbinp-outbin;
- X if (check = outbinp-outbin) {
- X putc(':', fbuf);
- X puthex(check, fbuf);
- X puthex(olddollar>>8, fbuf);
- X puthex(olddollar, fbuf);
- X puthex(0, fbuf);
- X check += (olddollar >> 8) + olddollar;
- X olddollar += (outbinp-outbin);
- X for (p=outbin; p<outbinp; p++) {
- X puthex(*p, fbuf);
- X check += *p;
- X }
- X puthex(256-check, fbuf);
- X putc('\n', fbuf);
- X outbinp = outbin;
- X }
- X}
- X
- X
- X
- X/*
- X * put out one byte of hex
- X */
- Xputhex(byte, buf)
- Xchar byte;
- XFILE *buf;
- X{
- X putc(hexadec[(byte >> 4) & 017], buf);
- X putc(hexadec[byte & 017], buf);
- X}
- X
- X/*
- X * put out a line of output -- also put out binary
- X */
- Xlist(optarg)
- Xint optarg;
- X{
- X register char * p;
- X register int i;
- X int lst;
- X
- X if (!expptr)
- X linecnt++;
- X addtoline('\0');
- X if (pass2) {
- X lst = iflist();
- X if (lst) {
- X lineout();
- X if (nopt)
- X fprintf(fout, "%4d:\t", linein[now_in]);
- X puthex(optarg >> 8, fout);
- X puthex(optarg, fout);
- X fputs(" ", fout);
- X for (p = emitbuf; (p < emitptr) && (p - emitbuf < 4); p++) {
- X puthex(*p, fout);
- X }
- X for (i = 4 - (p-emitbuf); i > 0; i--)
- X fputs(" ", fout);
- X putc('\t', fout);
- X fputs(linebuf, fout);
- X }
- X
- X if (bopt) {
- X for (p = emitbuf; p < emitptr; p++)
- X putbin(*p);
- X }
- X
- X
- X p = emitbuf+4;
- X while (lst && gopt && p < emitptr) {
- X lineout();
- X if (nopt) putc('\t', fout);
- X fputs(" ", fout);
- X for (i = 0; (i < 4) && (p < emitptr);i++) {
- X puthex(*p, fout);
- X p++;
- X }
- X putc('\n', fout);
- X }
- X
- X
- X lsterr2(lst);
- X } else
- X lsterr1();
- X dollarsign += emitptr - emitbuf;
- X emitptr = emitbuf;
- X lineptr = linebuf;
- X}
- X
- X
- X
- X/*
- X * keep track of line numbers and put out headers as necessary
- X */
- Xlineout()
- X{
- X if (line == 60) {
- X if (popt)
- X putc('\014', fout); /* send the form feed */
- X else
- X fputs("\n\n\n\n\n", fout);
- X line = 0;
- X }
- X if (line == 0) {
- X fprintf(fout, "\n\n%s %s\t%s\t Page %d\n\n\n",
- X &timp[4], &timp[20], title, page++);
- X line = 4;
- X }
- X line++;
- X}
- X
- X
- X/*
- X * cause a page eject
- X */
- Xeject()
- X{
- X if (pass2 && iflist()) {
- X if (popt) {
- X putc('\014', fout); /* send the form feed */
- X } else {
- X while (line < 65) {
- X line++;
- X putc('\n', fout);
- X }
- X }
- X }
- X line = 0;
- X}
- X
- X
- X/*
- X * space n lines on the list file
- X */
- Xspace(n)
- X{
- X int i ;
- X if (pass2 && iflist())
- X for (i = 0; i<n; i++) {
- X lineout();
- X putc('\n', fout);
- X }
- X}
- X
- X
- X/*
- X * Error handling - pass 1
- X */
- Xlsterr1() {
- X register int i;
- X if (topt)
- X for (i = 0; i <= 4; i++)
- X if (err[i]) {
- X errorprt(i);
- X err[i] = 0;
- X }
- X}
- X
- X
- X/*
- X * Error handling - pass 2.
- X */
- Xlsterr2(lst)
- Xint lst;
- X{
- X register int i;
- X for (i=0; i<FLAGS; i++)
- X if (err[i]) {
- X if (lst) {
- X lineout();
- X putc(errlet[i], fout);
- X putc('\n', fout);
- X }
- X err[i] = 0;
- X keeperr[i]++;
- X if (i > 4 && topt)
- X errorprt(i);
- X }
- X
- X fflush(fout); /*to avoid putc(har) mix bug*/
- X}
- X
- X/*
- X * print diagnostic to error terminal
- X */
- Xerrorprt(errnum)
- Xint errnum;
- X{
- X fprintf(stderr,"%d: %s error\n%s\n",
- X linecnt, errname[errnum], linebuf) ;
- X fflush(stderr) ;
- X return ;
- X}
- X
- X
- X/*
- X * list without address -- for comments and if skipped lines
- X */
- Xlist1()
- X{
- X int lst;
- X
- X addtoline('\0');
- X lineptr = linebuf;
- X if (!expptr) linecnt++;
- X if (pass2)
- X if (lst = iflist()) {
- X lineout();
- X if (nopt)
- X fprintf(fout, "%4d:\t", linein[now_in]);
- X fprintf(fout, "\t\t%s", linebuf);
- X lsterr2(lst);
- X }
- X else
- X lsterr1();
- X}
- X
- X
- X/*
- X * see if listing is desired
- X */
- Xiflist()
- X{
- X register i, j;
- X
- X if (lston)
- X return(1) ;
- X if (lopt)
- X return(0);
- X if (*ifptr && !fopt)
- X return(0);
- X if (!lstoff && !expptr)
- X return(1);
- X j = 0;
- X for (i=0; i<FLAGS; i++)
- X if (err[i])
- X j++;
- X if (expptr)
- X return(mopt || j);
- X if (eopt && j)
- X return(1);
- X return(0);
- X}
- X
- X
- X%}
- X
- X%union {
- X struct item *itemptr;
- X int ival;
- X char *cval;
- X }
- X
- X%token <cval> STRING
- X%token <itemptr> NOOPERAND
- X%token <itemptr> ARITHC
- X%token ADD
- X%token <itemptr> LOGICAL
- X%token <itemptr> BIT
- X%token CALL
- X%token <itemptr> INCDEC
- X%token <itemptr> DJNZ
- X%token EX
- X%token <itemptr> IM
- X%token PHASE
- X%token DEPHASE
- X%token <itemptr> IN
- X%token JP
- X%token <itemptr> JR
- X%token LD
- X%token <itemptr> OUT
- X%token <itemptr> PUSHPOP
- X%token <itemptr> RET
- X%token <itemptr> SHIFT
- X%token <itemptr> RST
- X%token <itemptr> REGNAME
- X%token <itemptr> ACC
- X%token <itemptr> C
- X%token <itemptr> RP
- X%token <itemptr> HL
- X%token <itemptr> INDEX
- X%token <itemptr> AF
- X%token <itemptr> SP
- X%token <itemptr> MISCREG
- X%token F
- X%token <itemptr> COND
- X%token <itemptr> SPCOND
- X%token <ival> NUMBER
- X%token <itemptr> UNDECLARED
- X%token END
- X%token ORG
- X%token DEFB
- X%token DEFS
- X%token DEFW
- X%token EQU
- X%token DEFL
- X%token <itemptr> LABEL
- X%token <itemptr> EQUATED
- X%token <itemptr> WASEQUATED
- X%token <itemptr> DEFLED
- X%token <itemptr> MULTDEF
- X%token <ival> MOD
- X%token <ival> SHL
- X%token <ival> SHR
- X%token <ival> NOT
- X%token IF
- X%token ENDIF
- X%token <itemptr> ARGPSEUDO
- X%token <itemptr> LIST
- X%token <itemptr> MINMAX
- X%token MACRO
- X%token <itemptr> MNAME
- X%token <itemptr> OLDMNAME
- X%token ARG
- X%token ENDM
- X%token MPARM
- X%token <ival> ONECHAR
- X%token <ival> TWOCHAR
- X
- X%type <itemptr> label.part symbol
- X%type <ival> reg evenreg realreg mem pushable bcdesp bcdehlsp mar condition
- X%type <ival> spcondition parenexpr expression lxexpression
- X
- X%left '|' '^'
- X%left '&'
- X%nonassoc NOT
- X%left '+' '-'
- X%left '*' '/' MOD SHL SHR
- X%left UNARY
- X%%
- X
- X%{
- Xchar *cp;
- Xint i;
- X%}
- X
- Xprogram:
- X statements
- X|
- X error { error("file bad"); }
- X;
- X
- X
- Xstatements:
- X statement
- X|
- X statements statement
- X|
- X statements error {
- X fprintf(stderr,"statement error\n");
- X err[fflag]++;
- X quoteflag = 0;
- X while(yychar != '\n' && yychar != '\0') yychar = yylex();
- X list(dollarsign);
- X yyclearin;yyerrok;
- X }
- X;
- X
- X
- Xstatement:
- X label.part '\n' {
- X if ($1) list(dollarsign);
- X else list1();
- X }
- X|
- X label.part operation '\n' {
- X list(dollarsign);
- X }
- X|
- X symbol EQU expression '\n' {
- X switch($1->i_token) {
- X case UNDECLARED: case WASEQUATED:
- X $1->i_token = EQUATED;
- X $1->i_value = $3;
- X break;
- X default:
- X err[mflag]++;
- X $1->i_token = MULTDEF;
- X }
- X list($3);
- X }
- X|
- X symbol DEFL expression '\n' {
- X switch($1->i_token) {
- X case UNDECLARED: case DEFLED:
- X $1->i_token = DEFLED;
- X $1->i_value = $3;
- X break;
- X default:
- X err[mflag]++;
- X $1->i_token = MULTDEF;
- X }
- X list($3);
- X }
- X|
- X symbol MINMAX expression ',' expression '\n' {
- X switch ($1->i_token) {
- X case UNDECLARED: case DEFLED:
- X $1->i_token = DEFLED;
- X if ($2->i_value) /* max */
- X list($1->i_value = ($3 > $5? $3:$5));
- X else list($1->i_value = ($3 < $5? $3:$5));
- X break;
- X default:
- X err[mflag]++;
- X $1->i_token = MULTDEF;
- X list($1->i_value);
- X }
- X }
- X|
- X IF expression '\n' {
- X if (ifptr >= ifstmax)
- X error("Too many ifs");
- X else {
- X if (pass2) {
- X *++ifptr = *expifp++;
- X if (*ifptr != !(yypv[2].ival)) err[pflag]++;
- X } else {
- X if (expifp >= expifmax)
- X error("Too many ifs!");
- X *expifp++ = !(yypv[2].ival);
- X *++ifptr = !(yypv[2].ival);
- X }
- X }
- X saveopt = fopt;
- X fopt = 1;
- X list(yypv[2].ival);
- X fopt = saveopt;
- X }
- X|
- X ENDIF '\n' {
- X if (ifptr == ifstack) err[bflag]++;
- X else --ifptr;
- X list1();
- X }
- X|
- X label.part END '\n' {
- X list(dollarsign);
- X peekc = 0;
- X }
- X|
- X label.part END expression '\n' {
- X xeq_flag++;
- X xeq = $3;
- X list($3);
- X peekc = 0;
- X }
- X|
- X label.part DEFS expression '\n' {
- X if ($3 < 0) err[vflag]++;
- X list(dollarsign);
- X if ($3) {
- X flushbin();
- X dollarsign += $3;
- X olddollar = dollarsign;
- X }
- X }
- X|
- X ARGPSEUDO arg_on ARG arg_off '\n' {
- X list1();
- X switch ($1->i_value) {
- X
- X case 0: /* title */
- X lineptr = linebuf;
- X cp = tempbuf;
- X title = titlespace;
- X while ((*title++ = *cp++) && (title < &titlespace[TITLELEN]));
- X *title = 0;
- X title = titlespace;
- X break;
- X
- X case 1: /* rsym */
- X if (pass2) break;
- X insymtab(tempbuf);
- X break;
- X
- X case 2: /* wsym */
- X writesyms = malloc(strlen(tempbuf)+1);
- X strcpy(writesyms, tempbuf);
- X break;
- X case 3: /* include file */
- X next_source(tempbuf) ;
- X break ;
- X }
- X }
- X|
- X ARGPSEUDO arg_on '\n' arg_off {
- X fprintf(stderr,"ARGPSEUDO error\n");
- X err[fflag]++;
- X list(dollarsign);
- X }
- X|
- X LIST '\n' {
- X if ($1 != (struct item *) -1) $<ival>2 = 1;
- X goto dolopt; }
- X|
- X LIST expression '\n' {
- X dolopt:
- X linecnt++;
- X if (pass2) {
- X lineptr = linebuf;
- X switch ($1->i_value) {
- X case 0: /* list */
- X if ($2 < 0) lstoff = 1;
- X if ($2 > 0) lstoff = 0;
- X break;
- X
- X case 1: /* eject */
- X if ($2) eject();
- X break;
- X
- X case 2: /* space */
- X if ((line + $2) > 60) eject();
- X else space($2);
- X break;
- X
- X case 3: /* elist */
- X eopt = edef;
- X if ($2 < 0) eopt = 0;
- X if ($2 > 0) eopt = 1;
- X break;
- X
- X case 4: /* fopt */
- X fopt = fdef;
- X if ($2 < 0) fopt = 0;
- X if ($2 > 0) fopt = 1;
- X break;
- X
- X case 5: /* gopt */
- X gopt = gdef;
- X if ($2 < 0) gopt = 1;
- X if ($2 > 0) gopt = 0;
- X break;
- X
- X case 6: /* mopt */
- X mopt = mdef;
- X if ($2 < 0) mopt = 0;
- X if ($2 > 0) mopt = 1;
- X }
- X }
- X }
- X|
- X UNDECLARED MACRO parm.list '\n' {
- X $1->i_token = MNAME;
- X $1->i_value = mfptr;
- X mfseek(mfile, (long)mfptr, 0);
- X list1();
- X mlex() ;
- X parm_number = 0;
- X }
- X|
- X OLDMNAME MACRO {
- X $1->i_token = MNAME;
- X while (yychar != ENDM && yychar) {
- X while (yychar != '\n' && yychar)
- X yychar = yylex();
- X list1();
- X yychar = yylex();
- X }
- X while (yychar != '\n' && yychar) yychar = yylex();
- X list1();
- X yychar = yylex();
- X }
- X|
- X label.part MNAME al arg.list '\n' {
- X expand:
- X $2->i_uses++ ;
- X arg_flag = 0;
- X parm_number = 0;
- X list(dollarsign);
- X expptr++;
- X est = est2;
- X est[FLOC] = floc;
- X est[TEMPNUM] = (char *)exp_number++;
- X floc = (char *)($2->i_value);
- X mfseek(mfile, (long)floc, 0);
- X }
- X;
- X
- X
- Xlabel.part:
- X /*empty*/
- X { $$ = NULL; }
- X|
- X symbol ':' {
- X switch($1->i_token) {
- X case UNDECLARED:
- X if (pass2)
- X err[pflag]++;
- X else {
- X $1->i_token = LABEL;
- X $1->i_value = dollarsign;
- X }
- X break;
- X case LABEL:
- X if (!pass2) {
- X $1->i_token = MULTDEF;
- X err[mflag]++;
- X } else if ($1->i_value != dollarsign)
- X err[pflag]++;
- X break;
- X default:
- X err[mflag]++;
- X $1->i_token = MULTDEF;
- X }
- X }
- X;
- X
- X
- Xoperation:
- X NOOPERAND
- X { emit1($1->i_value, 0, 0, 1); }
- X|
- X JP expression
- X { emit(3, 0303, $2, $2 >> 8); }
- X|
- X CALL expression
- X { emit(3, 0315, $2, $2 >> 8); }
- X|
- X RST expression
- X { if ($2 > 7 || $2 < 0)
- X err[vflag]++;
- X emit(1, $1->i_value + (($2 & 7) << 3));
- X }
- X|
- X ADD ACC ',' expression
- X { emit1(0306, 0, $4, 3); }
- X|
- X ARITHC ACC ',' expression
- X { emit1(0306 + ($1->i_value << 3), 0, $4, 3); }
- X|
- X LOGICAL expression
- X { emit1(0306 | ($1->i_value << 3), 0, $2, 3); }
- X|
- X LOGICAL ACC ',' expression /* -cdk */
- X { emit1(0306 | ($1->i_value << 3), 0, $4, 3); }
- X|
- X ADD ACC ',' reg
- X { emit1(0200 + ($4 & 0377), $4, 0, 0); }
- X|
- X ARITHC ACC ',' reg
- X { emit1(0200 + ($1->i_value << 3) + ($4 & 0377), $4, 0, 0); }
- X|
- X LOGICAL reg
- X { emit1(0200 + ($1->i_value << 3) + ($2 & 0377), $2, 0, 0); }
- X|
- X LOGICAL ACC ',' reg /* -cdk */
- X { emit1(0200 + ($1->i_value << 3) + ($4 & 0377), $4, 0, 0); }
- X|
- X SHIFT reg
- X { emit1(0145400 + ($1->i_value << 3) + ($2 & 0377), $2, 0, 0); }
- X|
- X INCDEC reg
- X { emit1($1->i_value + (($2 & 0377) << 3) + 4, $2, 0, 0); }
- X|
- X ARITHC HL ',' bcdehlsp
- X { if ($1->i_value == 1)
- X emit(2,0355,0112+$4);
- X else
- X emit(2,0355,0102+$4);
- X }
- X|
- X ADD mar ',' bcdesp
- X { emitdad($2,$4); }
- X|
- X ADD mar ',' mar
- X {
- X if ($2 != $4) {
- X fprintf(stderr,"ADD mar, mar error\n");
- X err[fflag]++;
- X }
- X emitdad($2,$4);
- X }
- X|
- X INCDEC evenreg
- X { emit1(($1->i_value << 3) + ($2 & 0377) + 3, $2, 0, 1); }
- X|
- X PUSHPOP pushable
- X { emit1($1->i_value + ($2 & 0377), $2, 0, 1); }
- X|
- X BIT expression ',' reg
- X {
- X if ($2 < 0 || $2 > 7)
- X err[vflag]++;
- X emit1($1->i_value + (($2 & 7) << 3) + ($4 & 0377), $4, 0, 0);
- X }
- X|
- X JP condition ',' expression
- X { emit(3, 0302 + $2, $4, $4 >> 8); }
- X|
- X JP '(' mar ')'
- X { emit1(0351, $3, 0, 1); }
- X|
- X CALL condition ',' expression
- X { emit(3, 0304 + $2, $4, $4 >> 8); }
- X|
- X JR expression
- X { emitjr(030,$2); }
- X|
- X JR spcondition ',' expression
- X { emitjr($1->i_value + $2, $4); }
- X|
- X DJNZ expression
- X { emitjr($1->i_value, $2); }
- X|
- X RET
- X { emit(1, $1->i_value); }
- X|
- X RET condition
- X { emit(1, 0300 + $2); }
- X|
- X LD reg ',' reg
- X {
- X if (($2 & 0377) == 6 && ($4 & 0377) == 6) {
- X fprintf(stderr,"LD reg, reg error\n");
- X err[fflag]++;
- X }
- X emit1(0100 + (($2 & 7) << 3) + ($4 & 7),$2 | $4, 0, 0);
- X }
- X|
- X LD reg ',' expression
- X { emit1(6 + (($2 & 0377) << 3), $2, $4, 2); }
- X|
- X LD reg ',' '(' RP ')'
- X { if ($2 != 7) {
- X fprintf(stderr,"LD reg, (RP) error\n");
- X err[fflag]++;
- X }
- X else emit(1, 012 + $5->i_value);
- X }
- X|
- X LD reg ',' parenexpr
- X {
- X if ($2 != 7) {
- X fprintf(stderr,"LD reg, (expr) error\n");
- X err[fflag]++;
- X }
- X else emit(3, 072, $4, $4 >> 8);
- X }
- X|
- X LD '(' RP ')' ',' ACC
- X { emit(1, 2 + $3->i_value); }
- X|
- X LD parenexpr ',' ACC
- X { emit(3, 062, $2, $2 >> 8); }
- X|
- X LD reg ',' MISCREG
- X {
- X if ($2 != 7) {
- X fprintf(stderr,"LD reg, MISCREG error\n");
- X err[fflag]++;
- X }
- X else emit(2, 0355, 0127 + $4->i_value);
- X }
- X|
- X LD MISCREG ',' ACC
- X { emit(2, 0355, 0107 + $2->i_value); }
- X|
- X LD evenreg ',' lxexpression
- X { emit1(1 + ($2 & 060), $2, $4, 5); }
- X|
- X LD evenreg ',' parenexpr
- X {
- X if (($2 & 060) == 040)
- X emit1(052, $2, $4, 5);
- X else
- X emit(4, 0355, 0113 + $2, $4, $4 >> 8);
- X }
- X|
- X LD parenexpr ',' evenreg
- X {
- X if (($4 & 060) == 040)
- X emit1(042, $4, $2, 5);
- X else
- X emit(4, 0355, 0103 + $4, $2, $2 >> 8);
- X }
- X|
- X LD evenreg ',' mar
- X {
- X if ($2 != 060) {
- X fprintf(stderr,"LD evenreg error\n");
- X err[fflag]++;
- X }
- X else
- X emit1(0371, $4, 0, 1);
- X }
- X|
- X EX RP ',' HL
- X {
- X if ($2->i_value != 020) {
- X fprintf(stderr,"EX RP, HL error\n");
- X err[fflag]++;
- X }
- X else
- X emit(1, 0353);
- X }
- X|
- X EX AF ',' AF setqf '\'' clrqf
- X { emit(1, 010); }
- X|
- X EX '(' SP ')' ',' mar
- X { emit1(0343, $6, 0, 1); }
- X|
- X IN realreg ',' parenexpr
- X {
- X if ($2 != 7) {
- X fprintf(stderr,"IN reg, (expr) error\n");
- X err[fflag]++;
- X }
- X else {
- X if ($4 < 0 || $4 > 255)
- X err[vflag]++;
- X emit(2, $1->i_value, $4);
- X }
- X }
- X|
- X IN realreg ',' '(' C ')'
- X { emit(2, 0355, 0100 + ($2 << 3)); }
- X|
- X IN F ',' '(' C ')'
- X { emit(2, 0355, 0160); }
- X|
- X OUT parenexpr ',' ACC
- X {
- X if ($2 < 0 || $2 > 255)
- X err[vflag]++;
- X emit(2, $1->i_value, $2);
- X }
- X|
- X OUT '(' C ')' ',' realreg
- X { emit(2, 0355, 0101 + ($6 << 3)); }
- X|
- X IM expression
- X {
- X if ($2 > 2 || $2 < 0)
- X err[vflag]++;
- X else
- X emit(2, $1->i_value >> 8, $1->i_value + (($2 + ($2 > 0)) << 3));
- X }
- X|
- X PHASE expression
- X {
- X if (phaseflag) {
- X err[oflag]++;
- X } else {
- X phaseflag = 1;
- X phdollar = dollarsign;
- X dollarsign = $2;
- X phbegin = dollarsign;
- X }
- X }
- X|
- X DEPHASE
- X {
- X if (!phaseflag) {
- X err[oflag]++;
- X } else {
- X phaseflag = 0;
- X dollarsign = phdollar + dollarsign - phbegin;
- X }
- X }
- X|
- X ORG expression
- X {
- X if (phaseflag) {
- X err[oflag]++;
- X dollarsign = phdollar + dollarsign - phbegin;
- X phaseflag = 0;
- X }
- X if ($2-dollarsign) {
- X flushbin();
- X olddollar = $2;
- X dollarsign = $2;
- X }
- X }
- X|
- X DEFB db.list
- X|
- X DEFW dw.list
- X|
- X ENDM
- X;
- X
- X
- Xparm.list:
- X|
- X parm.element
- X|
- X parm.list ',' parm.element
- X;
- X
- X
- Xparm.element:
- X UNDECLARED
- X {
- X $1->i_token = MPARM;
- X if (parm_number >= PARMMAX)
- X error("Too many parameters");
- X $1->i_value = parm_number++;
- X }
- X;
- X
- X
- Xarg.list:
- X /* empty */
- X|
- X arg.element
- X|
- X arg.list ',' arg.element
- X;
- X
- X
- Xarg.element:
- X ARG
- X {
- X cp = malloc(strlen(tempbuf)+1);
- X est2[parm_number++] = cp;
- X strcpy(cp, tempbuf);
- X }
- X;
- Xreg:
- X realreg
- X|
- X mem
- X;
- Xrealreg:
- X REGNAME
- X {
- X $$ = $1->i_value;
- X }
- X|
- X ACC
- X {
- X $$ = $1->i_value;
- X }
- X|
- X C
- X {
- X $$ = $1->i_value;
- X }
- X;
- Xmem:
- X '(' HL ')'
- X {
- X $$ = 6;
- X }
- X|
- X '(' INDEX expression ')'
- X {
- X disp = $3;
- X $$ = ($2->i_value & 0177400) | 6;
- X }
- X|
- X '(' INDEX ')'
- X {
- X disp = 0;
- X $$ = ($2->i_value & 0177400) | 6;
- X }
- X;
- Xevenreg:
- X bcdesp
- X|
- X mar
- X;
- Xpushable:
- X RP
- X {
- X $$ = $1->i_value;
- X }
- X|
- X AF
- X {
- X $$ = $1->i_value;
- X }
- X|
- X mar
- X;
- Xbcdesp:
- X RP
- X {
- X $$ = $1->i_value;
- X }
- X|
- X SP
- X {
- X $$ = $1->i_value;
- X }
- X;
- Xbcdehlsp:
- X bcdesp
- X|
- X HL
- X {
- X $$ = $1->i_value;
- X }
- X;
- Xmar:
- X HL
- X {
- X $$ = $1->i_value;
- X }
- X|
- X INDEX
- X {
- X $$ = $1->i_value;
- X }
- X;
- Xcondition:
- X spcondition
- X|
- X COND
- X {
- X $$ = $1->i_value;
- X }
- X;
- Xspcondition:
- X SPCOND
- X {
- X $$ = $1->i_value;
- X }
- X|
- X C
- X { $$ = 030; }
- X;
- Xdb.list:
- X db.list.element
- X|
- X db.list ',' db.list.element
- X;
- Xdb.list.element:
- X TWOCHAR
- X {
- X emit(2, $1, $1>>8);
- X }
- X|
- X STRING
- X {
- X cp = $1;
- X while (*cp != '\0')
- X emit(1,*cp++);
- X }
- X|
- X expression
- X {
- X if ($1 < -128 || $1 > 255)
- X err[vflag]++;
- X emit(1, $1 & 0377);
- X }
- X;
- X
- X
- Xdw.list:
- X dw.list.element
- X|
- X dw.list ',' dw.list.element
- X;
- X
- X
- Xdw.list.element:
- X expression
- X {
- X emit(2, $1, $1>>8);
- X }
- X;
- X
- X
- X
- Xlxexpression:
- X expression
- X|
- X TWOCHAR
- X;
- X
- Xparenexpr:
- X '(' expression ')'
- X { $$ = $2; }
- X;
- X
- Xexpression:
- X error
- X {
- X err[eflag]++;
- X $$ = 0;
- X }
- X|
- X LABEL
- X { $$ = $1->i_value; $1->i_uses++ ; }
- X|
- X NUMBER
- X|
- X ONECHAR
- X|
- X EQUATED
- X { $$ = $1->i_value; }
- X|
- X WASEQUATED
- X { $$ = $1->i_value; }
- X|
- X DEFLED
- X { $$ = $1->i_value; }
- X|
- X '$'
- X { $$ = dollarsign; }
- X|
- X UNDECLARED
- X {
- X err[uflag]++;
- X $$ = 0;
- X }
- X|
- X MULTDEF
- X { $$ = $1->i_value; }
- X|
- X expression '+' expression
- X { $$ = $1 + $3; }
- X|
- X expression '-' expression
- X { $$ = $1 - $3; }
- X|
- X expression '/' expression
- X { $$ = $1 / $3; }
- X|
- X expression '*' expression
- X { $$ = $1 * $3; }
- X|
- X expression MOD expression
- X { $$ = $1 % $3; }
- X|
- X expression '&' expression
- X { $$ = $1 & $3; }
- X|
- X expression '|' expression
- X { $$ = $1 | $3; }
- X|
- X expression '^' expression
- X { $$ = $1 ^ $3; }
- X|
- X expression SHL expression
- X { $$ = $1 << $3; }
- X|
- X expression SHR expression
- X { $$ = (($1 >> 1) & 077777) >> ($3 - 1); }
- X|
- X '[' expression ']'
- X { $$ = $2; }
- X|
- X NOT expression
- X { $$ = ~$2; }
- X|
- X '+' expression %prec UNARY
- X { $$ = $2; }
- X|
- X '-' expression %prec UNARY
- X { $$ = -$2; }
- X;
- X
- Xsymbol:
- X UNDECLARED
- X|
- X LABEL
- X|
- X MULTDEF
- X|
- X EQUATED
- X|
- X WASEQUATED
- X|
- X DEFLED
- X;
- X
- X
- Xal:
- X {
- X if (expptr >= MAXEXP)
- X error("Macro expansion level");
- X est2 = (char **) malloc((PARMMAX +4) * sizeof(char *));
- X expstack[expptr] = (char *)est2 ;
- X for (i=0; i<PARMMAX; i++)
- X est2[i] = 0;
- X arg_flag++;
- X }
- X;
- X
- X
- Xarg_on:
- X { arg_flag++; }
- X;
- X
- Xarg_off:
- X { arg_flag = 0; }
- X;
- X
- Xsetqf:
- X { quoteflag++; }
- X;
- X
- Xclrqf:
- X { quoteflag = 0; }
- X
- X;
- X
- X%%
- X/*extern int yylval;*/
- X
- X#define F_END 0
- X#define OTHER 1
- X#define SPACE 2
- X#define DIGIT 3
- X#define LETTER 4
- X#define STARTER 5
- X
- X
- X/*
- X * This is the table of character classes. It is used by the lexical
- X * analyser. (yylex())
- X */
- Xchar charclass[] = {
- X F_END, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
- X OTHER, SPACE, OTHER, OTHER, OTHER, SPACE, OTHER, OTHER,
- X OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
- X OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
- X SPACE, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
- X OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
- X DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT,
- X DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, STARTER,
- X STARTER,LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- X LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- X LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- X LETTER, LETTER, LETTER, OTHER, OTHER, OTHER, OTHER, LETTER,
- X OTHER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- X LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- X LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
- X LETTER, LETTER, LETTER, OTHER, OTHER, OTHER, OTHER, OTHER,
- X};
- X
- X
- X/*
- X * the following table tells which characters are parts of numbers.
- X * The entry is non-zero for characters which can be parts of numbers.
- X */
- Xchar numpart[] = {
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0,
- X '0', '1', '2', '3', '4', '5', '6', '7',
- SHAR_EOF
- echo "3" > ._seq_
- --
- "If I'd known it was harmless, I'd have killed it myself" Phillip K. Dick
- Bob Bownes, aka iii, aka captain comrade doktor bobwrench
- 3 A Pinehurst Ave, Albany, New York, 12203, (518)-482-8798 voice
- bownesrm@beowulf.uucp {uunet!steinmetz,rutgers!brspyr1}!beowulf!bownesrm
-